/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.action;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import vical.controller.EntryController;
import vical.model.Internationalization;
import vical.view.EntryDialog;

/**
 * Action control for deleting an action.
 * Delete an entry from database and refresh the window.
 *
 * @author WoKe
 * @author Can
 */
public class DeleteEntryAction extends AbstractAction {

    private EntryDialog entryDialog;

    public DeleteEntryAction(EntryDialog entryDialog) {
        super(Internationalization.getString("calendar_delete_button"));
        putValue(MNEMONIC_KEY, Internationalization.getMnemonic("mnemonics_entry_dialog_delete"));
        
        this.entryDialog = entryDialog;
    }

    public void actionPerformed(ActionEvent e) {

        EntryController.deleteEntry(entryDialog.getEntryFromInterface());

        entryDialog.dispose();
    }
}
